import java.util.Scanner;

public class day230411 {
    // 公共子串计算

    // 动态规划
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] arr1 = sc.nextLine().toCharArray();
        char[] arr2 = sc.nextLine().toCharArray();
        int m = arr1.length;
        int n = arr2.length;

        // 多定义一行一列, 用来表示以第0个字符结尾的子串
        int[][] dp = new int[m + 1][n + 1];
        // 初始化
        dp[0][0] = 0;

        // 记录最大长度
        int maxLen = 0;

        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (arr1[i - 1] == arr2[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    if (dp[i][j] > maxLen) {
                        // 更新长度
                        maxLen = dp[i][j];
                    }
                } else {
                    dp[i][j] = 0;
                }
            }
        }

        System.out.println(maxLen);
    }

    // 暴力
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        String str1 = in.nextLine();
        String str2 = in.nextLine();
        int ret = 0;
        for (int i = 0; i < str1.length(); i++) {
            String tmp1 = str1.substring(i);
            for (int j = 0; j < str2.length(); j++) {
                String tmp2 = str2.substring(j);
                int count = count(tmp1, tmp2);
                ret = Math.max(ret, count);
            }
        }
        System.out.println(ret);
    }

    private static int count(String str1, String str2) {
        int count = 0;
        int i = 0;
        int j = 0;
        while (i < str1.length() && j < str2.length()
                && str1.charAt(i) == str2.charAt(j)) {
            count++;
            i++;
            j++;
        }
        return count;
    }

    // 字符串反转
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        char[] arr = str.toCharArray();
        int start = 0;
        int end = arr.length - 1;
        while (start < end) {
            char tmp = arr[start];
            arr[start] = arr[end];
            arr[end] = tmp;
            start++;
            end--;
        }
        System.out.println(arr);
    }
}
